package cn.itcast.controller;

import cn.itcast.common.R;
import cn.itcast.dto.OrdersDto;
import cn.itcast.entity.Orders;
import cn.itcast.entity.Page;
import cn.itcast.service.IOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;
import java.util.List;

@RestController
@RequestMapping("/order")
public class OrderController extends BaseController{
    @Autowired
    private IOrderService orderService;
    @PostMapping("/submit")
    public R<String> submit(@RequestBody Orders orders){
        orderService.submit(orders,findIdFromSession());


        return R.success("支付成功");
    }
    @GetMapping("page")
    public R<Page<Orders>>  page(Integer page, Integer pageSize, String number, String beginTime, String endTime){
       Page<Orders> orders = orderService.page(page,pageSize,number,beginTime,endTime);
       return R.success(orders);
    }

    @GetMapping("userPage")
    public R<Page<OrdersDto>> userPage(Integer page,Integer pageSize){
      Page<OrdersDto> pageInfo = orderService.userPage(page,pageSize,findIdFromSession());
      return R.success(pageInfo);

    }

}
